import unittest

from api.employee import employeeApi
from utils import common_assert


class TestEmployee(unittest.TestCase):
    employee_id = None
    def setUp(self) -> None:
        self.employee_api = employeeApi()

    def test01_add_employee(self):
        employee_data = {
            "username": "Sam09",
            "mobile": "1311212089",
            "timeOfEntry": "2020-07-09",
            "formOfEmployment": 1,
            "workNumber": "111139",
            "departmentName": "销售",
            "departmentId": "1266699057968001024",
            "correctionTime": "2020-07-30T16:00:00.000Z"
        }
        response = self.employee_api.add_employee(employee_data)
        print(response.json())
        common_assert(self,response)
        TestEmployee.employee_id = response.json().get("data").get("id")
        print(TestEmployee.employee_id)


    def test02_update_employee(self):
        update_employee_data = {
           "username":"sala01"
        }
        response = self.employee_api.update_employee(TestEmployee.employee_id,update_employee_data)
        print(response.json())
        common_assert(self, response)

    def test03_get_employee(self):
        response = self.employee_api.get_employee(TestEmployee.employee_id)
        print(response.json())
        common_assert(self,response)

    def test04_delete(self):
        response = self.employee_api.delete_employee(TestEmployee.employee_id)
        print(response.json())
        common_assert(self, response)







